<!DOCTYPE html>
<html lang=en>
<head>
    <!-- so meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="Lambda表达式lambda表达式语法格式1(parameters) -&amp;gt; expression 或 (parameters) -&amp;gt;&amp;#123; statements; &amp;#125;  实例1234567891011121314&#x2F;&#x2F; 1. 不需要参数,返回值为 5  () -&amp;gt; 5    &#x2F;&#x2F; 2. 接收一个参数(数字类型),返回其2倍的值  x -&amp;gt; 2 * x">
<meta name="keywords" content="Java,笔记">
<meta property="og:type" content="article">
<meta property="og:title" content="Java学习笔记">
<meta property="og:url" content="http:&#x2F;&#x2F;yoursite.com&#x2F;2019&#x2F;09&#x2F;21&#x2F;Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0&#x2F;index.html">
<meta property="og:site_name" content="ECIN&#39;S BLOG">
<meta property="og:description" content="Lambda表达式lambda表达式语法格式1(parameters) -&amp;gt; expression 或 (parameters) -&amp;gt;&amp;#123; statements; &amp;#125;  实例1234567891011121314&#x2F;&#x2F; 1. 不需要参数,返回值为 5  () -&amp;gt; 5    &#x2F;&#x2F; 2. 接收一个参数(数字类型),返回其2倍的值  x -&amp;gt; 2 * x">
<meta property="og:locale" content="en">
<meta property="og:updated_time" content="2019-11-13T02:50:02.528Z">
<meta name="twitter:card" content="summary">
    
    
        
          
              <link rel="shortcut icon" href="/images/favicon.ico">
          
        
        
          
            <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
          
        
        
          
            <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
          
        
    
    <!-- title -->
    <title>Java学习笔记</title>
    <!-- styles -->
    <link rel="stylesheet" href="/css/style.css">
    <!-- persian styles -->
    
      <link rel="stylesheet" href="/css/rtl.css">
    
    <!-- rss -->
    
    
</head>

<body class="max-width mx-auto px3 ltr">
    
      <div id="header-post">
  <a id="menu-icon" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="menu-icon-tablet" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="top-icon-tablet" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');" style="display:none;"><i class="fas fa-chevron-up fa-lg"></i></a>
  <span id="menu">
    <span id="nav">
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects_url">Projects</a></li>
        
      </ul>
    </span>
    <br/>
    <span id="actions">
      <ul>
        
        <li><a class="icon" href="/2019/09/21/CentOS%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8%20%E5%9F%BA%E7%A1%80%E6%93%8D%E4%BD%9C%20%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5MySql/"><i class="fas fa-chevron-left" aria-hidden="true" onmouseover="$('#i-prev').toggle();" onmouseout="$('#i-prev').toggle();"></i></a></li>
        
        
        <li><a class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up" aria-hidden="true" onmouseover="$('#i-top').toggle();" onmouseout="$('#i-top').toggle();"></i></a></li>
        <li><a class="icon" href="#"><i class="fas fa-share-alt" aria-hidden="true" onmouseover="$('#i-share').toggle();" onmouseout="$('#i-share').toggle();" onclick="$('#share').toggle();return false;"></i></a></li>
      </ul>
      <span id="i-prev" class="info" style="display:none;">Previous post</span>
      <span id="i-next" class="info" style="display:none;">Next post</span>
      <span id="i-top" class="info" style="display:none;">Back to top</span>
      <span id="i-share" class="info" style="display:none;">Share post</span>
    </span>
    <br/>
    <div id="share" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" target="_blank" rel="noopener"><i class="fab fa-facebook " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&text=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-twitter " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&title=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-linkedin " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&is_video=false&description=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-pinterest " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=Java学习笔记&body=Check out this article: http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" target="_blank" rel="noopener"><i class="fas fa-envelope " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&title=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-get-pocket " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&title=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-reddit " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&title=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-stumbleupon " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&title=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-digg " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&name=Java学习笔记&description=" target="_blank" rel="noopener"><i class="fab fa-tumblr " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&t=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-hacker-news " aria-hidden="true"></i></a></li>
</ul>

    </div>
    <div id="toc">
      <ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#Lambda表达式"><span class="toc-number">1.</span> <span class="toc-text">Lambda表达式</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#lambda表达式语法格式"><span class="toc-number">1.0.1.</span> <span class="toc-text">lambda表达式语法格式</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#实例"><span class="toc-number">1.0.2.</span> <span class="toc-text">实例</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#输出Hello-world"><span class="toc-number">1.0.3.</span> <span class="toc-text">输出Hello world</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#实现自己的函数式接口"><span class="toc-number">1.1.</span> <span class="toc-text">实现自己的函数式接口</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#添加新的接口"><span class="toc-number">1.1.1.</span> <span class="toc-text">添加新的接口</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#实现方法"><span class="toc-number">1.1.2.</span> <span class="toc-text">实现方法</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#调用方法"><span class="toc-number">1.1.3.</span> <span class="toc-text">调用方法</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#这个跟上面的例子很像，使用Lembda表达式可以传递一个函数，可以将函数的动作传递到参数中，通过参数可以调用接口的方法，这个方法就是用Lembda表达式传递的动作实现的。"><span class="toc-number">1.1.4.</span> <span class="toc-text">这个跟上面的例子很像，使用Lembda表达式可以传递一个函数，可以将函数的动作传递到参数中，通过参数可以调用接口的方法，这个方法就是用Lembda表达式传递的动作实现的。</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Lambda表达式可以极大地简化匿名内部类的代码，举个例子，java8之前监听按钮时这样的"><span class="toc-number">1.2.</span> <span class="toc-text">Lambda表达式可以极大地简化匿名内部类的代码，举个例子，java8之前监听按钮时这样的</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#使用Lambda表达式之后"><span class="toc-number">1.2.1.</span> <span class="toc-text">使用Lambda表达式之后</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#便利集合也非常方便"><span class="toc-number">1.3.</span> <span class="toc-text">便利集合也非常方便</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#遍历一个list"><span class="toc-number">1.3.1.</span> <span class="toc-text">遍历一个list</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#遍历HashMap"><span class="toc-number">1.3.2.</span> <span class="toc-text">遍历HashMap</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#使用Lambda的Map和Reduce"><span class="toc-number">1.4.</span> <span class="toc-text">使用Lambda的Map和Reduce</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#Map"><span class="toc-number">1.4.1.</span> <span class="toc-text">Map</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#Reduce（折叠操作）"><span class="toc-number">1.4.2.</span> <span class="toc-text">Reduce（折叠操作）</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#过滤"><span class="toc-number">1.5.</span> <span class="toc-text">过滤</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#线程"><span class="toc-number">2.</span> <span class="toc-text">线程</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#线程池"><span class="toc-number">2.0.1.</span> <span class="toc-text">线程池</span></a></li></ol></li></ol></li></ol>
    </div>
  </span>
</div>

    
    <div class="content index py4">
        
        <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
  <header>
    
    <h1 class="posttitle" itemprop="name headline">
        Java学习笔记
    </h1>



    <div class="meta">
      <span class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
        <span itemprop="name">ECIN'S BLOG</span>
      </span>
      
    <div class="postdate">
      
        <time datetime="2019-09-20T19:05:21.000Z" itemprop="datePublished">2019-09-21</time>
        
      
    </div>


      

      
    <div class="article-tag">
        <i class="fas fa-tag"></i>
        <a class="tag-link" href="/tags/Java/" rel="tag">Java</a>, <a class="tag-link" href="/tags/%E7%AC%94%E8%AE%B0/" rel="tag">笔记</a>
    </div>


    </div>
  </header>
  

  <div class="content" itemprop="articleBody">
    <h4 id="Lambda表达式"><a href="#Lambda表达式" class="headerlink" title="Lambda表达式"></a>Lambda表达式</h4><h6 id="lambda表达式语法格式"><a href="#lambda表达式语法格式" class="headerlink" title="lambda表达式语法格式"></a>lambda表达式语法格式</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">(parameters) -&gt; expression 或 (parameters) -&gt;&#123; statements; &#125;</span><br></pre></td></tr></table></figure>

<h6 id="实例"><a href="#实例" class="headerlink" title="实例"></a>实例</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 1. 不需要参数,返回值为 5  </span></span><br><span class="line">() -&gt; <span class="number">5</span>  </span><br><span class="line">  </span><br><span class="line"><span class="comment">// 2. 接收一个参数(数字类型),返回其2倍的值  </span></span><br><span class="line">x -&gt; <span class="number">2</span> * x  </span><br><span class="line">  </span><br><span class="line"><span class="comment">// 3. 接受2个参数(数字),并返回他们的差值  </span></span><br><span class="line">(x, y) -&gt; x – y  </span><br><span class="line">  </span><br><span class="line"><span class="comment">// 4. 接收2个int型整数,返回他们的和  </span></span><br><span class="line">(<span class="keyword">int</span> x, <span class="keyword">int</span> y) -&gt; x + y  </span><br><span class="line">  </span><br><span class="line"><span class="comment">// 5. 接受一个 string 对象,并在控制台打印,不返回任何值(看起来像是返回void)  </span></span><br><span class="line">(String s) -&gt; System.out.print(s)</span><br></pre></td></tr></table></figure>

<h6 id="输出Hello-world"><a href="#输出Hello-world" class="headerlink" title="输出Hello world"></a>输出Hello world</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">    Greet greet = messag -&gt; System.out.println(<span class="string">"Hello "</span>+messag);</span><br><span class="line">    greet.sayMsg(<span class="string">"world"</span>);</span><br><span class="line">&#125;</span><br><span class="line"><span class="class"><span class="keyword">interface</span> <span class="title">Greet</span></span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">void</span> <span class="title">sayMsg</span><span class="params">(String message)</span></span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">    Caculate caculate = (<span class="keyword">int</span> x,<span class="keyword">int</span> y) -&gt; x-y;</span><br><span class="line">    System.out.println(caculate.add(<span class="number">1</span>,<span class="number">2</span>));</span><br><span class="line">&#125;</span><br><span class="line"><span class="class"><span class="keyword">interface</span> <span class="title">Caculate</span></span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">int</span> <span class="title">add</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y)</span></span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h5 id="实现自己的函数式接口"><a href="#实现自己的函数式接口" class="headerlink" title="实现自己的函数式接口"></a>实现自己的函数式接口</h5><p>比用使用颜色模式来填充指定长宽的颜色</p>
<p><strong>注意！！@FunctionalInterface注解标记函数接口。第一，编译器会检查出被注解实体是一个带有单个抽象方法的接口。第二，javadoc页面会包含该接口是函数时接口的声明。</strong></p>
<h6 id="添加新的接口"><a href="#添加新的接口" class="headerlink" title="添加新的接口"></a>添加新的接口</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">@<span class="meta">@FunctionalInterface</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">PiexlFunction</span> </span>&#123;</span><br><span class="line">	<span class="function">Color <span class="title">apply</span><span class="params">(<span class="keyword">int</span> x, <span class="keyword">int</span> y)</span></span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h6 id="实现方法"><a href="#实现方法" class="headerlink" title="实现方法"></a>实现方法</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="function">BufferedImage <span class="title">createImage</span> <span class="params">(<span class="keyword">int</span> width, <span class="keyword">int</span> height, PixelFunction f)</span> </span>&#123;</span><br><span class="line">	BufferedImage image = <span class="keyword">new</span> BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">for</span> (<span class="keyword">int</span> x = <span class="number">0</span>; x &lt; width; x++)&#123;</span><br><span class="line">		<span class="keyword">for</span> (<span class="keyword">int</span> y = <span class="number">0</span>; y &lt; height; y++) &#123;</span><br><span class="line">			Color color = f.apply(x, y);</span><br><span class="line">			image.setRGB(x, y, color.getRGB());</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h6 id="调用方法"><a href="#调用方法" class="headerlink" title="调用方法"></a>调用方法</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">BufferedImage frenchFlag = createImage(<span class="number">150</span>, <span class="number">100</span>, (x, y) -&gt; x &lt; <span class="number">50</span> ? Color.BLUE : x &lt; <span class="number">100</span> ? Color.WHITE : Color.RED);</span><br></pre></td></tr></table></figure>

<h6 id="这个跟上面的例子很像，使用Lembda表达式可以传递一个函数，可以将函数的动作传递到参数中，通过参数可以调用接口的方法，这个方法就是用Lembda表达式传递的动作实现的。"><a href="#这个跟上面的例子很像，使用Lembda表达式可以传递一个函数，可以将函数的动作传递到参数中，通过参数可以调用接口的方法，这个方法就是用Lembda表达式传递的动作实现的。" class="headerlink" title="这个跟上面的例子很像，使用Lembda表达式可以传递一个函数，可以将函数的动作传递到参数中，通过参数可以调用接口的方法，这个方法就是用Lembda表达式传递的动作实现的。"></a>这个跟上面的例子很像，使用Lembda表达式可以传递一个函数，可以将函数的动作传递到参数中，通过参数可以调用接口的方法，这个方法就是用Lembda表达式传递的动作实现的。</h6><h5 id="Lambda表达式可以极大地简化匿名内部类的代码，举个例子，java8之前监听按钮时这样的"><a href="#Lambda表达式可以极大地简化匿名内部类的代码，举个例子，java8之前监听按钮时这样的" class="headerlink" title="Lambda表达式可以极大地简化匿名内部类的代码，举个例子，java8之前监听按钮时这样的"></a>Lambda表达式可以极大地简化匿名内部类的代码，举个例子，java8之前监听按钮时这样的</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">JButton btn = <span class="keyword">new</span> JButton();</span><br><span class="line">btn.addActionListener(<span class="keyword">new</span> ActionListener() &#123;</span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">actionPerformed</span><span class="params">(ActionEvent e)</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<h6 id="使用Lambda表达式之后"><a href="#使用Lambda表达式之后" class="headerlink" title="使用Lambda表达式之后"></a>使用Lambda表达式之后</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">JButton btn = <span class="keyword">new</span> JButton();</span><br><span class="line">btn.addActionListener((e) -&gt; &#123;&#125;);</span><br></pre></td></tr></table></figure>

<h5 id="便利集合也非常方便"><a href="#便利集合也非常方便" class="headerlink" title="便利集合也非常方便"></a>便利集合也非常方便</h5><h6 id="遍历一个list"><a href="#遍历一个list" class="headerlink" title="遍历一个list"></a>遍历一个list</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// java8以前</span></span><br><span class="line">List&lt;String&gt; list = Arrays.asList(<span class="string">"Alien"</span>,<span class="string">"Bob"</span>,<span class="string">"Candy"</span>);</span><br><span class="line"><span class="keyword">for</span> (String str : list)&#123;</span><br><span class="line">System.out.println(str);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 使用Lambda表达式</span></span><br><span class="line">list.forEach(str -&gt; System.out.println(str));</span><br><span class="line">list.forEach(System.out::println);</span><br></pre></td></tr></table></figure>

<h6 id="遍历HashMap"><a href="#遍历HashMap" class="headerlink" title="遍历HashMap"></a>遍历HashMap</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">HashMap&lt;Integer, String&gt; map = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line">map.put(<span class="number">1</span>, <span class="string">"One"</span>);</span><br><span class="line">map.put(<span class="number">2</span>, <span class="string">"Two"</span>);</span><br><span class="line">map.put(<span class="number">3</span>, <span class="string">"Three"</span>);</span><br><span class="line">map.put(<span class="number">4</span>, <span class="string">"Four"</span>);</span><br><span class="line"></span><br><span class="line">map.forEach((k,v) -&gt; &#123;</span><br><span class="line">    System.out.println(k+<span class="string">":"</span>+v);</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<h5 id="使用Lambda的Map和Reduce"><a href="#使用Lambda的Map和Reduce" class="headerlink" title="使用Lambda的Map和Reduce"></a>使用Lambda的Map和Reduce</h5><h6 id="Map"><a href="#Map" class="headerlink" title="Map"></a>Map</h6><p>为1-8每个数都加上1，然后打印</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">List&lt;Integer&gt; num = Arrays.asList(<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>);</span><br><span class="line">num.stream().map((add) -&gt; add+<span class="number">1</span>).forEach(System.out::println);</span><br></pre></td></tr></table></figure>

<p>原理：首先将 (add) -&gt; add+1 表达式传到map方法，然后stream将其应用到流的每一个元素。然后foreach打印出来。</p>
<h6 id="Reduce（折叠操作）"><a href="#Reduce（折叠操作）" class="headerlink" title="Reduce（折叠操作）"></a>Reduce（折叠操作）</h6><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">List&lt;Integer&gt; num = Arrays.asList(<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>);</span><br><span class="line"><span class="keyword">int</span> all = num.stream().map((add) -&gt; add+<span class="number">1</span>).reduce((sum,add)-&gt;sum+add).get();</span><br><span class="line">System.out.println(all);</span><br></pre></td></tr></table></figure>

<h5 id="过滤"><a href="#过滤" class="headerlink" title="过滤"></a>过滤</h5><p>输出大于5的数</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">List&lt;Integer&gt; integerList = Arrays.asList(<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>, <span class="number">10</span>);</span><br><span class="line">System.out.println(integerList.stream().filter(x -&gt; (x &gt; <span class="number">5</span>)).collect(Collectors.toList()));</span><br></pre></td></tr></table></figure>



<h4 id="线程"><a href="#线程" class="headerlink" title="线程"></a>线程</h4><h6 id="线程池"><a href="#线程池" class="headerlink" title="线程池"></a>线程池</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">newCachedThreadPool</span><br><span class="line">——创建一个可缓存线程池，如果线程池长度超过处理需要，可灵活回收空闲线程，若无可回收，则新建线程。</span><br><span class="line"></span><br><span class="line">newFixedThreadPool</span><br><span class="line">——创建一个定长线程池，可控制线程最大并发数，超出的线程会在队列中等待。</span><br><span class="line"></span><br><span class="line">newScheduledThreadPool</span><br><span class="line">——创建一个定长线程池，支持定时及周期性任务执行。</span><br><span class="line"></span><br><span class="line">newSingleThreadExecutor</span><br><span class="line">创建一个单线程化的线程池，它只会用唯一的工作线程来执行任务，保证所有任务按照指定顺序(FIFO, LIFO, 优先级)执行。</span><br><span class="line"></span><br><span class="line">如：创建一个最大任务为5的线程池</span><br><span class="line">ExecutorService executorService = Executors.newFixedThreadPool(5);</span><br></pre></td></tr></table></figure>

<pre><code>或者</code></pre><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//五个参数的构造函数</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="title">ThreadPoolExecutor</span><span class="params">(<span class="keyword">int</span> corePoolSize, <span class="keyword">int</span> maximumPoolSize, <span class="keyword">long</span> keepAliveTime, TimeUnit unit, BlockingQueue&lt;Runnable&gt; workQueue)</span></span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function"><span class="comment">//六个参数的构造函数-1</span></span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="title">ThreadPoolExecutor</span><span class="params">(<span class="keyword">int</span> corePoolSize, <span class="keyword">int</span> maximumPoolSize, <span class="keyword">long</span> keepAliveTime, TimeUnit unit, BlockingQueue&lt;Runnable&gt; workQueue, ThreadFactory threadFactory)</span></span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function"><span class="comment">//六个参数的构造函数-2</span></span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="title">ThreadPoolExecutor</span><span class="params">(<span class="keyword">int</span> corePoolSize, <span class="keyword">int</span> maximumPoolSize, <span class="keyword">long</span> keepAliveTime, TimeUnit unit, BlockingQueue&lt;Runnable&gt; workQueue, RejectedExecutionHandler handler)</span></span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function"><span class="comment">//七个参数的构造函数</span></span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="title">ThreadPoolExecutor</span><span class="params">(<span class="keyword">int</span> corePoolSize, <span class="keyword">int</span> maximumPoolSize, <span class="keyword">long</span> keepAliveTime, TimeUnit unit, BlockingQueue&lt;Runnable&gt; workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)</span></span></span><br></pre></td></tr></table></figure>

<ul>
<li><strong>int corePoolSize：</strong>该线程池中<strong>核心线程数最大值</strong> </li>
</ul>
<blockquote>
<p><strong>核心线程：</strong>线程池新建线程的时候，如果当前线程总数小于corePoolSize，则新建的是核心线程，如果超过corePoolSize，则新建的是非核心线程核心线程默认情况下会一直存活在线程池中，即使这个核心线程啥也不干(闲置状态)。<br>如果指定ThreadPoolExecutor的allowCoreThreadTimeOut这个属性为true，那么核心线程如果不干活(闲置状态)的话，超过一定时间(时长下面参数决定)，就会被销毁掉。</p>
</blockquote>
<ul>
<li><strong>int maximumPoolSize：</strong> 该线程池中<strong>线程总数最大值</strong> </li>
</ul>
<blockquote>
<p>线程总数 = 核心线程数 + 非核心线程数。</p>
</blockquote>
<ul>
<li><strong>long keepAliveTime：</strong>该线程池中<strong>非核心线程闲置超时时长</strong> </li>
</ul>
<blockquote>
<p>一个非核心线程，如果不干活(闲置状态)的时长超过这个参数所设定的时长，就会被销毁掉，如果设置allowCoreThreadTimeOut = true，则会作用于核心线程。</p>
</blockquote>
<ul>
<li><strong>TimeUnit unit：</strong>keepAliveTime的单位</li>
</ul>
<blockquote>
<p>TimeUnit是一个枚举类型，其包括：<br>NANOSECONDS ： 1微毫秒 = 1微秒 / 1000<br>MICROSECONDS ： 1微秒 = 1毫秒 / 1000<br>MILLISECONDS ： 1毫秒 = 1秒 /1000<br>SECONDS ： 秒<br>MINUTES ： 分<br>HOURS ： 小时<br>DAYS ： 天</p>
</blockquote>
<ul>
<li><strong>BlockingQueue workQueue：</strong>该线程池中的任务队列：维护着等待执行的Runnable对象</li>
</ul>
<blockquote>
<p>当所有的核心线程都在干活时，新添加的任务会被添加到这个队列中等待处理，如果队列满了，则新建非核心线程执行任务。<br>常用的workQueue类型：</p>
</blockquote>
<ul>
<li><strong>SynchronousQueue</strong>：这个队列接收到任务的时候，会直接提交给线程处理，而不保留它，如果所有线程都在工作怎么办？那就新建一个线程来处理这个任务！所以为了保证不出现&lt;线程数达到了maximumPoolSize而不能新建线程&gt;的错误，使用这个类型队列的时候，maximumPoolSize一般指定成Integer.MAX_VALUE，即无限大</li>
<li><strong>LinkedBlockingQueue</strong>：这个队列接收到任务的时候，如果当前线程数小于核心线程数，则新建线程(核心线程)处理任务；如果当前线程数等于核心线程数，则进入队列等待。由于这个队列没有最大值限制，即所有超过核心线程数的任务都将被添加到队列中，这也就导致了maximumPoolSize的设定失效，因为总线程数永远不会超过corePoolSize</li>
<li><strong>ArrayBlockingQueue</strong>：可以限定队列的长度，接收到任务的时候，如果没有达到corePoolSize的值，则新建线程(核心线程)执行任务，如果达到了，则入队等候，如果队列已满，则新建线程(非核心线程)执行任务，又如果总线程数到了maximumPoolSize，并且队列也满了，则发生错误</li>
<li><strong>DelayQueue</strong>：队列内元素必须实现Delayed接口，这就意味着你传进去的任务必须先实现Delayed接口。这个队列接收到任务时，首先先入队，只有达到了指定的延时时间，才会执行任务</li>
<li><strong>ThreadFactory threadFactory：</strong>创建线程的方式，这是一个接口，你new他的时候需要实现他的Thread newThread(Runnable r)方法，一般用不上。</li>
<li><strong>RejectedExecutionHandler handler：</strong>这玩意儿就是抛出异常专用的，比如上面提到的两个错误发生了，就会由这个handler抛出异常，根本用不上。</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">new</span> ThreadPoolExecutor(<span class="number">1</span>, </span><br><span class="line">                       <span class="number">1</span>,</span><br><span class="line">                       <span class="number">0L</span>, TimeUnit.MILLISECONDS,</span><br><span class="line">                       <span class="keyword">new</span> LinkedBlockingQueue&lt;Runnable&gt;());</span><br><span class="line"><span class="keyword">new</span> ThreadPoolExecutor(<span class="number">1</span>,</span><br><span class="line">                       <span class="number">1</span>,</span><br><span class="line">                       <span class="number">0L</span>, TimeUnit.MILLISECONDS,</span><br><span class="line">                       <span class="keyword">new</span> LinkedBlockingQueue&lt;Runnable&gt;(),</span><br><span class="line">                                    threadFactory);</span><br><span class="line"><span class="keyword">new</span> ThreadPoolExecutor(<span class="number">0</span>, </span><br><span class="line">                       Integer.MAX_VALUE,</span><br><span class="line">                       <span class="number">60L</span>, TimeUnit.SECONDS,</span><br><span class="line">                       <span class="keyword">new</span> SynchronousQueue&lt;Runnable&gt;());</span><br><span class="line"><span class="keyword">new</span> ThreadPoolExecutor(<span class="number">0</span>, </span><br><span class="line">                       Integer.MAX_VALUE,</span><br><span class="line">                       <span class="number">60L</span>, TimeUnit.SECONDS,</span><br><span class="line">                       <span class="keyword">new</span> SynchronousQueue&lt;Runnable&gt;(),</span><br><span class="line">                       threadFactory);</span><br><span class="line">    </span><br><span class="line">    </span><br><span class="line">如:</span><br><span class="line">ExecutorService pool = <span class="keyword">new</span> ThreadPoolExecutor(</span><br><span class="line">	<span class="number">5</span>, </span><br><span class="line">	Integer.MAX_VALUE,</span><br><span class="line">    <span class="number">0L</span>, </span><br><span class="line">    TimeUnit.MILLISECONDS, </span><br><span class="line">    <span class="keyword">new</span> LinkedBlockingQueue&lt;Runnable&gt;());</span><br><span class="line">poor.execute(<span class="keyword">new</span> Runnable(***));</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">NCPU = CPU的数量</span><br><span class="line"></span><br><span class="line">UCPU = 期望对CPU的使用率 <span class="number">0</span> ≤ UCPU ≤ <span class="number">1</span></span><br><span class="line"></span><br><span class="line">W/C = 等待时间与计算时间的比率</span><br><span class="line"></span><br><span class="line">如果希望处理器达到理想的使用率，那么线程池的最优大小为：</span><br><span class="line"></span><br><span class="line">线程池大小=NCPU *UCPU(<span class="number">1</span>+W/C)</span><br><span class="line"></span><br><span class="line">在Java中使用</span><br><span class="line"></span><br><span class="line"><span class="keyword">int</span> ncpus = Runtime.getRuntime().availableProcessors();</span><br></pre></td></tr></table></figure>


  </div>
</article>



        
          <div id="footer-post-container">
  <div id="footer-post">

    <div id="nav-footer" style="display: none">
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects_url">Projects</a></li>
        
      </ul>
    </div>

    <div id="toc-footer" style="display: none">
      <ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#Lambda表达式"><span class="toc-number">1.</span> <span class="toc-text">Lambda表达式</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#lambda表达式语法格式"><span class="toc-number">1.0.1.</span> <span class="toc-text">lambda表达式语法格式</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#实例"><span class="toc-number">1.0.2.</span> <span class="toc-text">实例</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#输出Hello-world"><span class="toc-number">1.0.3.</span> <span class="toc-text">输出Hello world</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#实现自己的函数式接口"><span class="toc-number">1.1.</span> <span class="toc-text">实现自己的函数式接口</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#添加新的接口"><span class="toc-number">1.1.1.</span> <span class="toc-text">添加新的接口</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#实现方法"><span class="toc-number">1.1.2.</span> <span class="toc-text">实现方法</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#调用方法"><span class="toc-number">1.1.3.</span> <span class="toc-text">调用方法</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#这个跟上面的例子很像，使用Lembda表达式可以传递一个函数，可以将函数的动作传递到参数中，通过参数可以调用接口的方法，这个方法就是用Lembda表达式传递的动作实现的。"><span class="toc-number">1.1.4.</span> <span class="toc-text">这个跟上面的例子很像，使用Lembda表达式可以传递一个函数，可以将函数的动作传递到参数中，通过参数可以调用接口的方法，这个方法就是用Lembda表达式传递的动作实现的。</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Lambda表达式可以极大地简化匿名内部类的代码，举个例子，java8之前监听按钮时这样的"><span class="toc-number">1.2.</span> <span class="toc-text">Lambda表达式可以极大地简化匿名内部类的代码，举个例子，java8之前监听按钮时这样的</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#使用Lambda表达式之后"><span class="toc-number">1.2.1.</span> <span class="toc-text">使用Lambda表达式之后</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#便利集合也非常方便"><span class="toc-number">1.3.</span> <span class="toc-text">便利集合也非常方便</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#遍历一个list"><span class="toc-number">1.3.1.</span> <span class="toc-text">遍历一个list</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#遍历HashMap"><span class="toc-number">1.3.2.</span> <span class="toc-text">遍历HashMap</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#使用Lambda的Map和Reduce"><span class="toc-number">1.4.</span> <span class="toc-text">使用Lambda的Map和Reduce</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#Map"><span class="toc-number">1.4.1.</span> <span class="toc-text">Map</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#Reduce（折叠操作）"><span class="toc-number">1.4.2.</span> <span class="toc-text">Reduce（折叠操作）</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#过滤"><span class="toc-number">1.5.</span> <span class="toc-text">过滤</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#线程"><span class="toc-number">2.</span> <span class="toc-text">线程</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#线程池"><span class="toc-number">2.0.1.</span> <span class="toc-text">线程池</span></a></li></ol></li></ol></li></ol>
    </div>

    <div id="share-footer" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" target="_blank" rel="noopener"><i class="fab fa-facebook fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&text=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-twitter fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&title=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-linkedin fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&is_video=false&description=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-pinterest fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=Java学习笔记&body=Check out this article: http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" target="_blank" rel="noopener"><i class="fas fa-envelope fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&title=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-get-pocket fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&title=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-reddit fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&title=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-stumbleupon fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&title=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-digg fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&name=Java学习笔记&description=" target="_blank" rel="noopener"><i class="fab fa-tumblr fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=http://yoursite.com/2019/09/21/Java%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/&t=Java学习笔记" target="_blank" rel="noopener"><i class="fab fa-hacker-news fa-lg" aria-hidden="true"></i></a></li>
</ul>

    </div>

    <div id="actions-footer">
        <a id="menu" class="icon" href="#" onclick="$('#nav-footer').toggle();return false;"><i class="fas fa-bars fa-lg" aria-hidden="true"></i> Menu</a>
        <a id="toc" class="icon" href="#" onclick="$('#toc-footer').toggle();return false;"><i class="fas fa-list fa-lg" aria-hidden="true"></i> TOC</a>
        <a id="share" class="icon" href="#" onclick="$('#share-footer').toggle();return false;"><i class="fas fa-share-alt fa-lg" aria-hidden="true"></i> Share</a>
        <a id="top" style="display:none" class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up fa-lg" aria-hidden="true"></i> Top</a>
    </div>

  </div>
</div>

        
        <footer id="footer">
  <div class="footer-left">
    Copyright &copy; 2020 ECIN520
  </div>
  <div class="footer-right">
    <nav>
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects_url">Projects</a></li>
        
      </ul>
    </nav>
  </div>
</footer>

    </div>
    <!-- styles -->
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
<link rel="stylesheet" href="/lib/justified-gallery/css/justifiedGallery.min.css">

    <!-- jquery -->
<script src="/lib/jquery/jquery.min.js"></script>
<script src="/lib/justified-gallery/js/jquery.justifiedGallery.min.js"></script>
<!-- clipboard -->

  <script src="/lib/clipboard/clipboard.min.js"></script>
  <script type="text/javascript">
  $(function() {
    // copy-btn HTML
    var btn = "<span class=\"btn-copy tooltipped tooltipped-sw\" aria-label=\"Copy to clipboard!\">";
    btn += '<i class="far fa-clone"></i>';
    btn += '</span>'; 
    // mount it!
    $(".highlight table").before(btn);
    var clip = new ClipboardJS('.btn-copy', {
      text: function(trigger) {
        return Array.from(trigger.nextElementSibling.querySelectorAll('.code')).reduce((str,it)=>str+it.innerText+'\n','')
      }
    });
    clip.on('success', function(e) {
      e.trigger.setAttribute('aria-label', "Copied!");
      e.clearSelection();
    })
  })
  </script>

<script src="/js/main.js"></script>
<!-- search -->

<!-- Google Analytics -->

<!-- Baidu Analytics -->

<!-- Disqus Comments -->


</body>
</html>
